/**
 * @author kongolou (bilibili: 七秒Qimiao, tieba: 头发干衣服穿)
 * @date 2023-12-14
 * @brief 此脚本用于演示 [PE] 无套神之八炮 的 ch6 阵解。
 * 
 * [阵名] [PE] 无套神之八炮
 * [阵解] ch6: I-PP | PP | I-PP | PP (12 | 6 | 12 | 6)
 * [出场僵尸] 普僵，跳跳，舞王，潜水，冰车，小丑，矿工，海豚，扶梯，白眼，红眼，蹦极
 * [出场植物] 寒冰菇，复制-寒冰菇，咖啡豆，睡莲，三叶草，樱桃炸弹，四大垫材
 * [炮序] 33+56, 43+26, 35+47, 45+37
 * [存冰位] 39, 49, 25, 55, 15, 65
 * [第一波入轨] PP 入轨
 * [第九波脱轨] PP 波，处理第九波的红眼共需四门炮，发射两炮后点冰压制
 * [第十波入轨] PP 入轨，蹦极留到第十一波（减速波）冰杀
 * [第十九波脱轨] I-PP 波，处理第十九波红眼共需四门炮
 * [第二十波收尾] 冰消珊瑚，炮杀蹦极，留边路残红回冰
 */
#include <avz.h>

void AScript()
{
    AAssumeWavelength({
        ATime(1, 601), ATime(2, 1200), ATime(3, 601), ATime(4, 1200),
        ATime(5, 601), ATime(6, 1200), ATime(7, 601), ATime(8, 1200),
        ATime(10, 601), ATime(11, 1200), ATime(12, 601), ATime(13, 1200),
        ATime(14, 601), ATime(15, 1200), ATime(16, 601), ATime(17, 1200),
        ATime(18, 601)
    });
    ASetZombies({
        APJ_0, ATT_4, AWW_8, 
        AQS_11, ABC_12, AHT_14, 
        AXC_15, AKG_17, ABJ_20,
        AFT_21, ABY_23, AHY_32 
    });
    ASelectCards({
        AICE_SHROOM, AM_ICE_SHROOM, 
        ACOFFEE_BEAN, ALILY_PAD, 
        ABLOVER, ACHERRY_BOMB,  
        APUFF_SHROOM, ASUN_SHROOM,
        ASCAREDY_SHROOM, AFLOWER_POT
    });
    AConnect(ATime(1, -599), [=] {
        aCobManager.SetList({{3, 3}, {5, 6}, {4, 3}, {2, 6}, {3, 5}, {4, 7}, {4, 5}, {3, 7}});
        aIceFiller.Start({{3, 9}, {4, 9}, {2, 5}, {5, 5}, {1, 5}, {6, 5}});
    });
    // 加速波
    for (auto wave : {1, 3, 5, 7, 10, 12, 14, 16, 18}) {
        // 加速波开炮时机 = 舞王召唤 342cs - 炮落地时长 373cs
        AConnect(ATime(wave, 341 - 373), [=] {
            aCobManager.Fire({{2, 9}, {5, 9}});
        });
    }
    // 减速波
    for (auto wave : {2, 4, 6, 8, 11, 13, 15, 17}) {
        // 减速波前 298cs 点预判冰
        AConnect(ATime(wave, -298 + 1), [=] {
            aIceFiller.Coffee();
        });
        // 减速波开炮时机 = 减速波波长 1200cs - 炮落地时长 373cs  - 刷新时间 200cs
        AConnect(ATime(wave, 1200 - 373 - 200), [=] {
            aCobManager.Fire({{2, 9}, {5, 9}});
        });
    }
    // 第九波
    AConnect(ATime(9, 341 - 373), [=] {
        aCobManager.Fire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aIceFiller.Coffee();
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
    });
    // 第十九波
    AConnect(ATime(19, -298 + 1), [=] {
        aIceFiller.Coffee();
    });
    AConnect(ATime(19, 1200 - 373 - 200), [=] {
        aCobManager.Fire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
    });
    // 第二十波
    AConnect(ATime(20, -298 + 1), [] {
        // 冰消珊瑚
        aIceFiller.Coffee();
        // 停止存冰
        aIceFiller.Pause();
    });
    AConnect(ATime(20, 300), [=] {
        // 冰生效 3s 后，炮杀蹦极
        aCobManager.Fire({{2, 2}, {5, 2}});
    });
    AConnect(ATime(20, 1200 - 373 - 200), [=] {
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        aCobManager.RecoverFire({{2, 9}, {5, 9}});
        // 留边路残红回冰
        aCobManager.RecoverFire({{3, 9}, {4, 9}});
    });
}